package com.cxhc.demo1006;

import com.cxhc.demo1006.module.GirlsBean;
import com.cxhc.demo1006.net.NetClient;

import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.Scheduler;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

class MainModule {

    public void getGirls(int page,final ImainModuleCallBack callBack) {
        MainService mainService = NetClient.getInstance().createMainService();
        Observable<GirlsBean> girls = mainService.getGirls(page);
        girls.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<GirlsBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(GirlsBean girlsBean) {
                        callBack.getDataSucceess(girlsBean);
                    }

                    @Override
                    public void onError(Throwable e) {
                        callBack.getDataError();
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}
